/*
 * Snake controller.
 */

#include <iostream>
#include <vector>
#include "SnakeObject.h"
#include "SnakeApple.h"
#include <glut.h>
#include <gl/GL.h>

/**
 * \def SNAKE_START_LENGTH
 * \brief Starting length of the snake.
 */
#define SNAKE_START_LENGTH 3

#define KB_ENTER 13

/**
 * \class Snake
 * \brief Snake controller.
 * \see SnakeObject
 *
 * Controller of the snake game. It maintains the list of SnakeObjects.
 */
class Snake
{
public:
	Snake();
	~Snake();

	/**
	 * \brief Update the snake controller.
	 *
	 * All variables will be updated before they can be written to the screen.
	 */
	void SnakeUpdate();
	void InitList();
	void SnakeDisplay();
	SnakeObject& operator [] (int index);
	void SnakeRelocate(int index);
	SnakeApple& GetSnakeApple();
	void AddSnakeObject();
	bool CheckSelfHit();
	
	/**
	 * \brief Return the size of the internal list.
	 */
	int size();

private:
	std::vector <SnakeObject> objlist;
	SnakeApple apple;

	// algo
	int length;
	int n;
	int s;
};
